package com.sx.zongzhi.adapter;


import android.content.Context;
import android.view.View;
import android.widget.CheckBox;

import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.AppealTypeBean;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.List;

/**
 * Created by XZY on 2017/11/23.
 * 述求服务类型列表的adapter
 */
public class AppealTypeListAdapter extends CommonAdapter<AppealTypeBean.RowsBean> {


    public AppealTypeListAdapter(Context context, int layoutId, List<AppealTypeBean.RowsBean> datas) {
        super(context, layoutId, datas);
    }

    EventTypeCallback mCallback;


    @Override
    protected void convert(ViewHolder viewHolder, final AppealTypeBean.RowsBean item, int position) {
        CheckBox checkBox=viewHolder.getView(R.id.checkbox);
        checkBox.setText(item.getDictName());
        checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.getData(item);
                }
            }
        });

    }

    /**
     * 定义一个接口
     */
    public interface EventTypeCallback {
        void getData(AppealTypeBean.RowsBean rowsBean);
    }

    /*接口回调*/
    public void getEventType(EventTypeCallback callback) {
        mCallback = callback;
    }
}
